package com.hefeng.example.service.impl;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.hefeng.example.domain.CustomerManualWorkOrder;
import com.hefeng.example.domain.DeviceAutomaticAlarmWorkOrder;
import com.hefeng.example.domain.WorkOrderDistribution;
import com.hefeng.example.mapper.WorkOrderDistributionMapper;
import com.hefeng.example.service.WorkUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class WorkUserServiceImpl extends ServiceImpl<WorkOrderDistributionMapper, WorkOrderDistribution> implements WorkUserService {
    @Autowired
    WorkOrderDistributionMapper workUserMapper;

    /**
     * 转派工单
     *
     * @param dispatcher
     * @param current
     * @param size
     * @return
     */
    @Override
    public Page<CustomerManualWorkOrder> getList(String dispatcher, long current, long size) {
        Page<CustomerManualWorkOrder> pagin = new Page<>(current, size, true);
        IPage<CustomerManualWorkOrder> selectResult = workUserMapper.listWorkOrderDistribution(dispatcher, pagin);
        pagin.setPages(selectResult.getPages());
        pagin.setTotal(selectResult.getTotal());
        pagin.setRecords(selectResult.getRecords());
        System.out.println("-------" + pagin);
        //3. 返回结果
        return pagin;
    }


    /**
     * 维保人员处理中工单列表
     *
     * @param dispatcher
     * @return
     */
//    @Override
//    public Page<CustomerManualWorkOrder> disposeingWork(String dispatcher , long current, long size) {
//        Page<CustomerManualWorkOrder> pagin = new Page<>(current,size  , true);
//        IPage<CustomerManualWorkOrder> selectResult = workUserMapper.disposeingAlarmWork(pagin,dispatcher);
//        pagin.setRecords(new ArrayList<>());
//        pagin.setPages(selectResult.getPages());
//        pagin.setTotal(selectResult.getTotal());
//        pagin.setRecords(selectResult.getRecords());
//        System.out.println("-------"+pagin);
//        //3. 返回结果
//        return pagin;
//
//    }

    /**
     * 维保人员逾期工单列表
     *
     * @param dispatcher
     * @return
     */
    @Override
    public List<Map> LateWork(String dispatcher) {
        return workUserMapper.LateWork(dispatcher);
    }

    @Override
    public List<Map> LateWorkT(String dispatcher) {
        return workUserMapper.LateWorkT(dispatcher);
    }


    /**
     * 已完成工单
     *
     * @param dispatcher
     * @return
     */
    @Override
    public List<Map> finishWork(String dispatcher) {
        return workUserMapper.finishWork(dispatcher);
    }

    @Override
    public List<Map> finishWorkT(String dispatcher) {
        return workUserMapper.finishWorkT(dispatcher);
    }


    @Override
    public int updateAlarm(DeviceAutomaticAlarmWorkOrder deviceAutomaticAlarmWorkOrder) {
        deviceAutomaticAlarmWorkOrder.setWorkStatus(1);
        return workUserMapper.updateAlarm(deviceAutomaticAlarmWorkOrder);
    }


    /**
     * 维保人员处理中工单列表
     *
     * @param dispatcher
     * @return
     */
    @Override
    public List<Map> disposeingManualWork(String dispatcher) {
        return workUserMapper.disposeingManualWork(dispatcher);
    }

    @Override
    public List<Map> disposeingWork(String dispatcher) {
        return workUserMapper.disposeingAlarmWork(dispatcher);
    }

}
